Conditions | 4 |
Paths | 10 |
Total Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | var chalk = require('chalk'); |
||
10 | hostile.get(preserveFormatting, function (err, lines) { |
||
11 | if (err) { |
||
12 | console.error(err.message); |
||
13 | } |
||
14 | lines.forEach(function (line) { |
||
15 | if ( line[0].trim() === '127.0.0.1' ) { |
||
16 | line[1].trim().split(' ').forEach(function(elem){ |
||
17 | if ( elem === server_name){ |
||
18 | found = true; |
||
19 | } |
||
20 | }); |
||
21 | } |
||
22 | }); |
||
23 | if ( !found ){ |
||
24 | process.stderr.write(chalk.yellow(emoji.emojify("[:raised_hand: ] Server hostname non found on local /etc/hosts \n"))); |
||
25 | if ( enviroment === 'dev' ){ |
||
26 | server_ip = '127.0.0.1'; |
||
27 | } |
||
28 | hostile.set(server_ip, server_name, function (err) { |
||
29 | if (err) { |
||
30 | if ( err.code === 'EACCES' && err.path === '/etc/hosts' ){ |
||
31 | process.stderr.write(chalk.bgRed.white(emoji.emojify("[:heavy_multiplication_x: ] Impossibile modificare il file automaticamente, \nrieseguire 'npm run check:hostfile' come admin o editare a mano opportuanmente il file\n"))); |
||
32 | } else { |
||
33 | process.stderr.write(chalk.bgRed.white(emoji.emojify("[:heavy_multiplication_x: ] Errore nel settaggio di /etc/hosts\n"))); |
||
34 | process.stderr.write(chalk.red(err+"\n")); |
||
35 | } |
||
36 | |||
37 | process.exit(1); |
||
|
|||
38 | } else { |
||
39 | process.stdout.write(chalk.bgGreen.black(emoji.emojify('[:heavy_check_mark: ] set /etc/hosts successfully!' + "\n"))); |
||
40 | } |
||
41 | }); |
||
42 | } else { |
||
43 | process.stdout.write(chalk.bgGreen.black(emoji.emojify('[:heavy_check_mark: ] /etc/hosts correct!' + "\n"))); |
||
44 | } |
||
45 | }); |
||
46 |